//
//  XiaoKaiItemsConfigCollectionViewCell.m
//  Project_A
//
//  Created by 凯 on 15/7/22.
//  Copyright (c) 2015年 zhoukaidong. All rights reserved.
//

#import "XiaoKaiItemsConfigCollectionViewCell.h"
#import "BaseHeader.h"
#import "UIImageView+WebCache.h"

@implementation XiaoKaiItemsConfigCollectionViewCell
-(void)dealloc
{
    [_image release];
    [_label release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.image = [[[UIImageView alloc]init]autorelease];
        [self.contentView addSubview:self.image];
        
        self.label = [[[UILabel alloc]init]autorelease];
        [self.contentView addSubview:self.label];
        
        self.pricelabel = [[[UILabel alloc]init]autorelease];
        [self.contentView addSubview:self.pricelabel];
    }
    return self;
}


-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    
    self.image.frame = CGRectMake(5, 5, SCREEN_WIDTH / 2 - 30, SCREEN_HEIGHT / 3 - 60);
    
    
    
    self.label.frame = CGRectMake(5, SCREEN_HEIGHT / 3 - 55, self.image.frame.size.width, 40);
    
    self.label.font = [UIFont systemFontOfSize:13];
    self.label.numberOfLines = 0;
    
    self.pricelabel.frame = CGRectMake(5, self.image.frame.size.height + self.label.frame.size.height, self.image.frame.size.width, 20);
    self.pricelabel.textColor = [UIColor colorWithRed:1 green:0.49 blue:0.71 alpha:1];
    self.pricelabel.textAlignment = NSTextAlignmentRight;
    self.label.font = [UIFont systemFontOfSize:13];
    self.label.textColor = [UIColor colorWithRed:1 green:0.49 blue:0.71 alpha:1];
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    
    self.contentView.backgroundColor = RGBACOLOR(230, 230, 230, 1);
    [self.contentView.layer setCornerRadius:10];
    self.contentView.clipsToBounds = YES;
    self.image.backgroundColor = [UIColor clearColor];
    self.label.backgroundColor = [UIColor clearColor];
    self.pricelabel.backgroundColor = [UIColor clearColor];
    
}
-(void)setModel:(UserModel *)model
{
    if ( _Model != model) {
        [_Model release];
        _Model = [model retain];
    }
    self.label.text = model.name;
    [self.image setImageWithURL:[NSURL URLWithString:model.image]];
    
    

    
}

@end
